/************** O T T R   C O P Y R I G H T   N O T I C E **************
 **                                                                   **
 ** © 2013 OTTR, Inc.  All rights reserved.                           **
 **                                                                   ** 
 *************** O T T R   C O P Y R I G H T   N O T I C E *************/

package com.jonathan.javatar;

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;

/**
 *
 * @author Jonathan Paz <jonathan.paz@ottr.com>
 */
public class TarFile implements Closeable {
    private boolean closed;
    private File file;
    public TarFile(String name) throws IOException {
        this(new File(name));
    }

    public TarFile(File file) throws IOException {
        this.file = file;
    }

    private void ensureOpen() throws IllegalStateException {
        if (closed) {
            throw new IllegalStateException("The file is closed");
        }
    }

    @Override
    public void close() throws IOException {
        if (!closed) {
            closed = true;
        }
    }

    public TarEntry getEntry(String name) {
        ensureOpen();
        return null;
    }

    public InputStream getInputStream(TarEntry entry) throws IOException {
        if (entry == null) {
            throw new NullPointerException();
        }
        ensureOpen();
        return null;
    }

    public String getName() {
        return file.getPath();
    }

    public Iterator<? extends TarEntry> entries() {
        ensureOpen();
        return null;
    }

    public int size() {
        return -1;
    }
}
